﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simple.Repository.Models
{
    /// <summary>
    /// 课程
    /// </summary>
    public class Course : BusinessFullEntityBase<Guid>
    {
        /// <summary>
        /// 课程名称
        /// </summary>
        public string? CourseName { get; set; }

        /// <summary>
        /// 课程分类
        /// </summary>
        public Guid? CourseTypeId { get; set; }

        /// <summary>
        /// 讲师id
        /// </summary>
        public Guid? LecturerId { get; set; }

        /// <summary>
        /// 课程分类
        /// </summary>
        public virtual CourseType? CourseType { get; set; }

        /// <summary>
        /// 讲师
        /// </summary>
        public virtual Lecturer? Lecturer { get; set; }

        /// <summary>
        /// 课程来源
        /// </summary>
        public EnumCourseSource Coursesource { get; set; } = EnumCourseSource.Myself;

        /// <summary>
        /// 时长（分钟）
        /// </summary>
        public double Duration { get; set; }

        /// <summary>
        /// 图片id
        /// </summary>
        public string? ImgId { get; set; }

        /// <summary>
        /// 视频id
        /// </summary>
        public string? VideosId { get; set; }

        /// <summary>
        /// 视频链接
        /// </summary>
        public string? VideosLink { get; set; }

        /// <summary>
        /// 是否启用
        /// true--启用
        /// </summary>
        public bool IsEnable { get; set; }

        /// <summary>
        /// 介绍
        /// </summary>
        public string? Description { get; set; }

        /// <summary>
        /// 点播次数
        /// </summary>
        public int? PlayCount { get; set; } = 0;


        public override void ConfigureEntity(ModelBuilder builder)
        {
            builder.Entity<Course>(entity =>
            {
                entity.HasOne(c => c.CourseType).WithMany(c => c.CourseList).HasForeignKey(c => c.CourseTypeId);
                entity.HasOne(c => c.Lecturer).WithMany(c => c.CourseList).HasForeignKey(c => c.LecturerId);
            });
        }
    }
}
